package com.gec.hawaste.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.gec.hawaste.entity.AppVersion;
import com.gec.hawaste.service.IAppVersionService;
import com.gec.hawaste.utils.PageInfo;
import com.gec.hawaste.utils.ResultBean;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author gec
 * @since 2022-07-01
 */
@RestController
//@RequestMapping("/hawaste/app-version")
@RequestMapping("/manager/app")
public class AppVersionController {

	@Autowired
	private IAppVersionService iAppVersionService;
	
	//查询
	@RequestMapping(value="select")
	public ResultBean<PageInfo>select(@RequestParam("current")int current,
										@RequestParam("size") int size){
		PageInfo<AppVersion> pageInfo = this.iAppVersionService.page(new
				PageInfo<AppVersion>(current,size)); 
		
		//设置分页条
		pageInfo.setNavigatePage();
		
		return ResultBean.ok(pageInfo);
	}
	
	//manager/app/selectOne
	
	@RequestMapping("selectOne")
	public ResultBean<AppVersion>selectOne(Long id){
		AppVersion appVersion =this.iAppVersionService.getById(id);
		System.out.println(appVersion);
		return ResultBean.ok(appVersion);
	}
	
	//manager/app/delete
	
	@RequestMapping("delete")
	public ResultBean<AppVersion>delete(Long id){
		 this.iAppVersionService.removeById(id);
		return ResultBean.ok();
	}
	
	//manager/app/saveOrUpdate
	
	@RequestMapping("saveOrUpdate")
	public ResultBean saveOrUpdate(@RequestBody AppVersion appVersion){
		System.out.println("app.id:"+appVersion.getId());
		this.iAppVersionService.saveOrUpdate(appVersion);
		return ResultBean.ok();
	}
	
}
